package de.iritgo.skillfull.director.attacktype;

import java.util.Random;

import de.iritgo.skillfull.Left4Alien;
import de.iritgo.skillfull.director.AttackStrategy;
import de.iritgo.skillfull.director.AttackType;
import de.iritgo.skillfull.entity.Entity;
import de.iritgo.skillfull.entity.EntityManager;
import de.iritgo.skillfull.entity.command.MoveFieldCommand;
import de.iritgo.skillfull.entity.command.SetPositionCommand;

public abstract class AbstractAttack implements AttackType 
{
	protected AttackStrategy attackStrategy;
	protected EntityManager entityManager;
	protected Random generator = new Random ();

	public AbstractAttack (AttackStrategy attackStrategy)
	{
		this.attackStrategy = attackStrategy;
		this.entityManager = (EntityManager) Left4Alien.getApplicationContext().getBean ("de.iritgo.skillfull.EntityManager"); 
	}

	protected void createEnemy (String entityPrototypeName, int x, int y, int moves, Entity.DST_FIELD direction) 
	{
		Entity alien = entityManager.getPrototypeEntity (entityPrototypeName);
		alien.addCommand (new SetPositionCommand (alien, x, y, false));
		for (int i = 1; i < moves; ++i)
			alien.addCommand (new MoveFieldCommand (alien, direction));
		alien.setName ("alien1" + entityManager.getNextId ());
		entityManager.addEntity (alien);
	}

	public abstract int attackBottom (int heroHealth, int enemies, int timeLeft);

	public abstract int attackLeft (int heroHealth, int currentEnemies, int timeLeft);

	public abstract int attackRight (int heroHealth, int enemies, int timeLeft);

	public abstract int attackTop (int heroHealth, int enemies, int timeLeft);
}
